﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace PivotViewerBase
{

    public class NamedColorValueConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            Color x = (Color)value;
            return new SolidColorBrush(x);        
        }
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

    public class BackgroundColorValueConverter : IValueConverter
    {

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var color = Colors.White;
            switch (value.ToString())
            {
                case "Mountain":
                    color = Color.FromArgb(255, 98, 62, 188);
                    break;
                case "Touring":
                    color = Color.FromArgb(255, 47, 139, 242);
                    break;
                case "Road":
                    color = Color.FromArgb(255, 95, 202, 2);
                    break;
                case "":
                    color = Colors.Transparent;
                    break;
                case "BM":
                    color = Colors.Black;
                    break;

                case "BS":
                    color = Colors.Cyan;
                    break;
                default:
                    if (value.ToString().EndsWith(":")||value.ToString().EndsWith("-"))
                        color = Colors.Transparent;
                    break;
            }

            return new SolidColorBrush(color);
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

    public class ForegroundColorValueConverter : IValueConverter
    {

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var color = Colors.White;
            switch (value.ToString())
            {
                case "BM":
                    color = Colors.Black;
                    break;

                case "BS":
                    color = Colors.Magenta;
                    break;
                default:
                    if (value.ToString().EndsWith(":") || value.ToString().EndsWith("-"))
                        color = Colors.Transparent;
                    break;
            }

            return new SolidColorBrush(color);
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

    public class YearToDateConverter : IValueConverter
    {

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return DateTime.Parse("1/1/" + value.ToString());
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
